package com.chixing.ih.module.programmer.service.Impl;

import com.chixing.ih.module.programmer.mapper.EduExperMapper;
import com.chixing.ih.module.programmer.mapper.ProgrammerMapper;
import com.chixing.ih.module.programmer.pojo.EduExper;
import com.chixing.ih.module.programmer.service.IEduExperService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * Description:
 *
 * @version 1.0
 * @Author MasterYan
 * @Date 2020/10/3
 * Time: 9:01
 */
@Service
@Transactional
public class EduExperServiceImpl implements IEduExperService {

    @Autowired
    EduExperMapper eduExperMapper;

    @Autowired
    ProgrammerMapper programmerMapper;

    @Override
    public boolean updateList(List<EduExper> eduExpers) {
        for (EduExper eduExper : eduExpers
        ) {
            int record = eduExperMapper.updateOne(eduExper);
            if (record == 0)
                return false;
        }
        return true;

    }

    @Override
    public List<EduExper> listAll(long userId) {
        List<EduExper> eduExpers = eduExperMapper.listAll(userId);
        return eduExpers;

    }

    @Override
    public EduExper saveList(EduExper eduExper) {

        int record = eduExperMapper.insertOne(eduExper);
        if (record > 0)
            return eduExper;
        return null;

    }

    @Override
    public boolean deleteEduExper(long id) {
        int record = eduExperMapper.deleteOne(id);
        if (record <= 0)
            return false;
        return true;
    }
}
